<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2.7.10/dist/vue.js"></script>
</head>

<body>
  <!-- 插槽：实现组件间的通信，父传子，子传父 -->
  <div id="app">
    <ml-a>
      <template #default>
        <div>我是插入的内容1 --- {{a}}</div>
      </template>
      <template #aa>
        <div>我是插入的内容2 --- {{b}}</div>
      </template>
      <template #bb="scoped">
        <div>我是插入的内容3 --- {{scoped.car}}</div>
      </template>
      <template #cc="{car}">
        <div>我是插入的内容4 --- {{car}}</div>
      </template>
    </ml-a>
  </div>
  <script>
    Vue.component("ml-a", {
      template: `
        <div>
          <div>我是ml-a组件 -- {{car}}</div>
          <slot name="default">
            <div>我是默认值1</div>
          </slot>
          <slot name="aa">
            <div>我是默认值2</div>
          </slot>
          <slot name="bb" :car="car">
            <div>我是默认值3</div>
          </slot>
          <slot name="cc" :car="car">
            <div>我是默认值4</div>
          </slot>
        </div>
      `,
      data() {
        return {
          car: "byd"
        }
      }
    })
    let vm = new Vue({
      el: "#app",
      data() {
        return {
          a: 1,
          b: 2
        }
      }
    });
  </script>
</body>

</html>